(function ($, window) {
    var baseRequest = window.baseRequest;
    var appConfig = window.appConfig;
    var commonTool = window.commonTool;
    var dataManager = window.dataManager;
    var locale = dataManager.getLocale();
    var baseUrl = appConfig.v3ServiceUrl + '/minihealth';

    var v3MiniHealth = window.v3MiniHealth = {};

    //add by dongjuanying

    //endac

    //add by zhangfuqiang
    var historyChangeUrl = baseUrl + '/home/history/change?';
    /**
     * 近一周健康趋势
     * @param apSN
     * @param mode
     * @param callback
     * @example https://oasis.h3c.com/v3/minihealth/home/history/change?apSN=219801A0YJ916AQ00033&mode=1
     */
    v3MiniHealth.getHistoryChange = function (apSN, mode, callback) {
    	console.log(apSN);
        baseRequest.commonGet(historyChangeUrl + $.param({apSN: apSN, mode: mode}), function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (data == -1 || data.errcode) {
                return callback(1,locale.base.err.devOffline);
            }
            callback(0, JSON.parse(data));
        });
    };

    var achievementUrl = baseUrl + '/home/history/achievement?';
    /**
     * 健康勋章
     * @param apSN
     * @param callback
     * @example https://oasis.h3c.com/v3/minihealth/home/history/achievement?apSN=219801A0YJ916AQ00033
     */
    v3MiniHealth.getAchievement = function (apSN, callback) {
        baseRequest.commonGet(achievementUrl + $.param({apSN: apSN}), function (code, data) {
            if (code === 2 || code === 1) {
                return callback(2);
            }
            if (code === '""') {
                return callback(1); // TODO err
            }
            return callback(0, JSON.parse(data));
        });
    };
    //end

    //add by ding

    //end

    //add by wangyu

    //end

    //add by wuchengcheng

    //end

})(mui, window);